﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Model/MP_InfoListBase.master" AutoEventWireup="true"
    CodeFile="KFXX_KeHuListInfo.aspx.cs" Inherits="Func_KHXX_KFXX_KeHuListInfo" %>

<%@ Register Src="../UC_ChildPageLoadButton.ascx" TagName="UC_ChildPageLoadButton"
    TagPrefix="uc1" %>
<%@ Register Src="../UC_ChildBarTitleButton.ascx" TagName="UC_ChildBarTitleButton"
    TagPrefix="uc3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cph_Head" runat="Server">
    <script type="text/javascript">
        var i = 0;
        $(function () {
            SetPanelSize();
            //            $('a').each(function (i) {
            //                this.onclick = function () {
            //                    alert('z');
            //                    return false;
            //                };
            //            });
            $('#tbDataGrid').datagrid({
                url: '../../Ajax/GetAjaxData.ashx',
                fit: true,
                pagination: true,
                sortName: 'CreateDate',
                sortOrder: 'ASC',
                striped: true,
                rownumbers: true,
                singleSelect: true,
                //                onSortColumn: sortChange, //点击字段排序后执行sortChang方法
                idField: 'sbid',
                pageSize: 5,
                pageList: [5, 10, 20],
                queryParams: { funcid: "KeHuSheBeiList", action: "query",
                    where: "kfid='" + $.getUrlVar('key') + "'", idField: 'sbid'
                },
                frozenColumns: [[
                    { title: '名称', field: 'mingcheng', width: 100, align: 'center', sortable: true },
                    { title: '品牌', field: 'shebeipinpai', width: 100, align: 'center', sortable: true },
                    { title: '型号', field: 'xinghao', width: 90, align: 'center', sortable: true}]],
                columns: [[
                    { title: '产水量', field: 'chanshuiliang', width: 80, align: 'center', sortable: true },
                    { title: '水质要求', field: 'shuizhiyaoqiu', width: 70, align: 'center', sortable: true },
                    { title: '销售商', field: 'xiaoshoushang', width: 120, align: 'center', sortable: true },
                    { title: '联系人', field: 'lianxiren', align: 'center', width: 100, sortable: true },
                    { title: '联系电话', field: 'lianxidianhua', align: 'center', width: 130, sortable: true },
                    { title: '安装时间', field: 'anzhuangshijian', width: 100, align: 'center', sortable: true, formatter: formatterdate },
                    { title: '建档时间', field: 'createdate', align: 'center', width: 120, sortable: true },
                    { title: '配套设备', align: 'left', width: 60, field: 'ptsb' }
            ]]
            , loadFilter: function (data) { //数据过滤
                for (var i = 0; i < data.rows.length; i++) {

                    data.rows[i].ptsb = '<a class="no-button" style="color:Blue" onclick="GetPeiTaoList(\'' +
                         data.rows[i].sbid + '\')">查看</a>';
                }
                return data;
            }
            });

            GetPeiTaoList('');
        })

        function formatterdate(val, row) {
            var date = new Date(val);
            var month = (date.getMonth() + 1);
            if (month < 10) {
                month = '0' + month;
            }
            var day = date.getDate();
            if (day < 10) {
                day = '0' + day;
            }
            return date.getFullYear() + '-' + month + '-' + day;
        }


        function GetPeiTaoList(sbid) {
            var whr = "kfid='" + $.getUrlVar('key') + "'";
            if (sbid.length > 0) {
                whr += " and sbid='" + sbid + "'";
            }
            $('#tbPeiTaoList').datagrid({
                url: '../../Ajax/GetAjaxData.ashx',
                fit: true,
                pagination: true,
                sortName: 'CreateDate',
                sortOrder: 'ASC',
                striped: true,
                rownumbers: true,
                singleSelect: true,
                pageSize: 5,
                pageList: [5, 10, 20],
                idField: 'ptid',
                queryParams: { funcid: "PeiTaoSheShiList", action: "query", where: whr, idField: 'ptid' },
                frozenColumns: [[
                    { title: '名称', field: 'peitaoshebei', width: 150, align: 'center', sortable: true },
                    { title: '品牌', field: 'pinpai', width: 150, align: 'center', sortable: true },
                    { title: '型号', field: 'xinghao', width: 100, align: 'center', sortable: true }
                ]],
                columns: [[
                    { title: '用水量', field: 'yongshuiliang', width: 100, align: 'center', sortable: true },
                    { title: '水质要求', field: 'shuizhiyaoqiu', width: 70, align: 'center', sortable: true },
                    { title: '销售商', field: 'xiaoshoushang', width: 120, align: 'center', sortable: true },
                    { title: '联系人', field: 'xiaoshoulianxiren', align: 'center', width: 100, sortable: true },
                    { title: '联系电话', field: 'xslianxidianhua', align: 'center', width: 130, sortable: true },
                    { title: '建档时间', field: 'createdate', align: 'center', width: 120, sortable: true }
            ]]
            })
        }

        function refreshgrid() {
            $("#tbDataGrid").datagrid("reload");
            $("#tbPeiTaoList").datagrid("reload");
        };

        window.onload = function () {
            var arr = document.getElementsByTagName('a');
            var btnID = '';
            for (var i = 0; i < arr.length; i++) {
                arr[i].onclick = function () {
                    btnID = this.id;
                    if (btnID.indexOf("_add") > 0) {
                        add(btnID);
                    }
                    else if (btnID.indexOf("_edit") > 0) {
                        edit_detail(btnID, 1);
                    }
                    else if (btnID.indexOf("_Delete") > 0) {
                        Delete(btnID);
                    }
                    else if (btnID.indexOf("_detail") > 0) {
                        edit_detail(btnID, 0);
                    }
                }
            }
        }


        //新增
        function add(objid) {
            var kid = $.getUrlVar("key");
            var url = '';
            if (objid.indexOf("ChildPageLoadButton1") > 0) {
                var url = "../Func/KHXX/KFXX_SheBeiEdit.aspx?funcid=KeHuSheBeiList&keyid=" + kid;
                top.openDialog(url, "shebei_edit", "设备-增加", 570, 360, 50, 50);
            }
            else {
                var sbkey = $('#tbDataGrid').datagrid('options').idField;
                var selectedRow = $('#tbDataGrid').datagrid('getSelected');
                if (selectedRow != null) {
                    url = "../Func/KHXX/KFXX_PeiTaoEdit.aspx?funcid=PeiTaoSheShiList&keyid=" + kid +
                        "&sbid=" + selectedRow[sbkey];
                    top.openDialog(url, "ptshebei_edit", "配套设备-增加", 570, 360, 50, 50);
                }
                else {
                    showWarningMsg("请选择需要添加的水机设备！");
                }
            }
        }

        //修改或查看
        function edit_detail(objid, objtype) {
            var title = '修改';
            var _url = '';
            if (objtype == 0) {
                title = '查看';
                _url = '&act=detail';
            }
            var kid, sbkey, selectedRow;
            kid = $.getUrlVar("key");
            if (objid.indexOf("ChildPageLoadButton1") > 0) {
                sbkey = $('#tbDataGrid').datagrid('options').idField;
                selectedRow = $('#tbDataGrid').datagrid('getSelected');
                if (selectedRow != null) {
                    url = "../Func/KHXX/KFXX_SheBeiEdit.aspx?funcid=KeHuSheBeiList&keyname=" + sbkey +
                        "&key=" + selectedRow[sbkey] + _url;
                    top.openDialog(url, "shebei_edit", "设备-" + title, 570, 360, 50, 50);
                } else {
                    showWarningMsg("请选中需要修改的数据！");
                }
            }
            else {
                sbkey = $('#tbPeiTaoList').datagrid('options').idField;
                selectedRow = $('#tbPeiTaoList').datagrid('getSelected');
                if (selectedRow != null) {
                    url = "../Func/KHXX/KFXX_PeiTaoEdit.aspx?funcid=PeiTaoSheShiList&keyname=" + sbkey +
                        "&key=" + selectedRow[sbkey] + _url;
                    top.openDialog(url, "ptshebei_edit", "配套设备-" + title, 570, 360, 50, 50);
                } else {
                    showWarningMsg("请选中需要修改的数据！");
                }
            }
        }

        function Delete(objid) {  //删除
            var kid, sbkey, selectedRow;
            var tbGrid = '';
            var funid = '';
            kid = $.getUrlVar("key");
            if (objid.indexOf("ChildPageLoadButton1") > 0) {
                tbGrid = 'tbDataGrid';
                funcid = 'KeHuSheBeiList';
            }
            else {
                tbGrid = 'tbPeiTaoList';
                funcid = 'PeiTaoSheShiList';
            }
            sbkey = $("#" + tbGrid + "").datagrid('options').idField;
            selectedRow = $("#" + tbGrid + "").datagrid('getSelected');
            if (selectedRow != null) {
                showConfirmMsg('要删除选中的数据吗？', function (r) {
                    if (r) {
                        $.post($("#" + tbGrid + "").datagrid('options').url, { "funcid": funcid,
                            "action": "delete", "where": sbkey + "='" + selectedRow[sbkey] + "'"
                        }, function (data) {
                            var json = eval("(" + data + ")")
                            if (json.success) {
                                $("#" + tbGrid + "").datagrid('deleteRow', $("#" + tbGrid + "").datagrid('getRowIndex', selectedRow));
                            }
                            showWarningMsg(json.message);
                        });
                    }
                })
            } else {
                showWarningMsg("请选中需要删除的数据！");
            }
        }

        function SetPanelSize() {
            var pageHeight = findDimensions(); //页面高度
            var _height = pageHeight - (29 * 3 + 10) - $('#tbInfo')[0].clientHeight;
            var _avgHeight = _height / 2;
            $('#divSJList').height(_avgHeight);
            $('#divPTList').height(_avgHeight);
        }

        function findDimensions() //函数：获取尺寸
        {
            //获取窗口高度
            if (window.innerHeight)
                winHeight = window.innerHeight;
            else if ((document.body) && (document.body.clientHeight))
                winHeight = document.body.clientHeight;

            //通过深入Document内部对body进行检测，获取窗口大小
            if (document.documentElement && document.documentElement.clientHeight) {
                winHeight = document.documentElement.clientHeight;
            }
            return winHeight;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cph_Content" runat="Server">
    <uc3:UC_ChildBarTitleButton ID="UC_ChildBarTitleButton1" runat="server" Menu_Name="客户信息" />
    <table id="tbInfo" border="0" cellpadding="0" cellspacing="0" class="frm" width="100%">
        <tr>
            <td width="9%" align="right">
                客户名称：
            </td>
            <td>
                <asp:TextBox Style="width: 98%;" ID="KeHuMingCheng" runat="server" ReadOnly="True"
                    class="txt"></asp:TextBox>
            </td>
            <td align="right">
                区域：
            </td>
            <td>
                <asp:TextBox Style="width: 98%;" ID="quyu" runat="server" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
            <td width="9%" align="right">
                地址：
            </td>
            <td width="24%">
                <asp:TextBox Style="width: 98%;" ID="KeHuDiZhi" runat="server" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td align="right">
                客户等级：
            </td>
            <td width="23%">
                <asp:TextBox Style="width: 98%;" ID="KeHuDengJiStr" runat="server" ReadOnly="True"
                    class="txt"></asp:TextBox>
            </td>
            <td width="9%" align="right">
                部门：
            </td>
            <td width="26%">
                <asp:TextBox Style="width: 98%;" ID="BuMen" runat="server" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
            <td align="right">
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="right">
                联系人：
            </td>
            <td>
                <asp:TextBox Style="width: 98%;" ID="LianXiRen" runat="server" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
            <td align="right">
                职务：
            </td>
            <td>
                <asp:TextBox Style="width: 98%;" ID="ZhiWu" runat="server" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
            <td align="right">
                手机：
            </td>
            <td>
                <asp:TextBox Style="width: 98%;" ID="ShouJi" runat="server" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td align="right">
                固定电话：
            </td>
            <td>
                <asp:TextBox Style="width: 98%;" ID="DianHua" runat="server" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
            <td align="right">
                传真：
            </td>
            <td>
                <asp:TextBox Style="width: 98%;" ID="ChuanZhen" runat="server" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
            <td align="right">
                邮箱：
            </td>
            <td>
                <asp:TextBox Style="width: 98%;" ID="YouXiang" runat="server" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td align="right">
                QQ：
            </td>
            <td>
                <asp:TextBox Style="width: 98%;" ID="QQ" runat="server" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
            <td align="right">
                微信：
            </td>
            <td>
                <asp:TextBox Style="width: 98%;" ID="WeiXin" runat="server" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="right">
                备注：
            </td>
            <td colspan="5">
                <asp:TextBox Style="width: 98%;" ID="BeiZhu" runat="server" TextMode="MultiLine"
                    Rows="2" ReadOnly="True" class="txt"></asp:TextBox>
            </td>
        </tr>
    </table>
    <uc1:UC_ChildPageLoadButton ID="UC_ChildPageLoadButton1" runat="server" Menu_Name="水机设备列表" />
    <div id="divSJList">
        <table id="tbDataGrid">
        </table>
    </div>
    <uc1:UC_ChildPageLoadButton ID="UC_ChildPageLoadButton2" runat="server" Menu_Name="配套设备列表" />
    <div id="divPTList">
        <table id="tbPeiTaoList">
        </table>
    </div>
    <input type="hidden" id="onclickID" />
</asp:Content>
